import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:whale/helper/utils/util.dart';
import 'package:whale/pages/means/main/widgets/selection/controller.dart';
import 'index.dart';

void showSelectionDialog({
  required double top,
  required SelectionModel md,
  required SelectionController controller,
}) {
  Get.dialog(
    Column(
      children: [
        InkWell(
          onTap: () {
            Get.back();
          },
          child: Container(
            child: SafeArea(
              top: false,
              child: Container(
                height: top,
              ),
            ),
          ),
        ),
        Container(
          color: Colors.white,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Container(
                constraints: BoxConstraints(
                  minHeight: 60.r,
                  maxHeight: Get.height -
                      top -
                      Get.bottomBarHeight -
                      120.r -
                      Get.statusBarHeight,
                ),
                child: SelectionContentView(
                  md: md,
                  controller: controller,
                ),
              ),
              SizedBox(
                height: 20.r,
              ),
              Container(
                height: 60.r,
                decoration: const BoxDecoration(
                  border: Border(
                    top: BorderSide(color: Colors.grey, width: 0.5),
                  ),
                ),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    InkWell(
                      onTap: () => controller.actionReset(md),
                      child: Container(
                        alignment: Alignment.center,
                        width: 120.r,
                        height: 50.r,
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            loadImage(
                              url: 'clean.png'.imgPathMeans,
                              width: 18.r,
                              fit: BoxFit.contain,
                            ),
                            Text(
                              '重置',
                              style: TextStyle(
                                  color: const Color(0xff515151),
                                  fontSize: 11.sp),
                            )
                          ],
                        ),
                      ),
                    ),
                    Expanded(
                        child: InkWell(
                      onTap: () => controller.actionSure(md),
                      child: Container(
                          alignment: Alignment.center,
                          margin: EdgeInsets.fromLTRB(10.r, 5.r, 16.r, 5.r),
                          height: 40.r,
                          decoration: BoxDecoration(
                              color: ColorsUtil.theme,
                              borderRadius: BorderRadius.circular(4.r)),
                          child: Text(
                            '确定',
                            style: TextStyle(
                              color: Colors.white,
                              fontSize: 14.sp,
                              fontWeight: FontWeight.bold,
                            ),
                          )),
                    ))
                  ],
                ),
              )
            ],
          ),
        ),
        Expanded(
          child: InkWell(
            onTap: Get.back,
            child: Container(
              color: Colors.black54,
            ),
          ),
        ),
      ],
    ),
    barrierColor: Colors.transparent,
    useSafeArea: false,
  );
}
